package com.ngc.mall.controller;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ngc.mall.common.configure.response.ResponseResult;
import com.ngc.mall.domain.SaleAdDomain;
import com.ngc.mall.service.ISaleAdService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/sale/ad")
public class SaleAdController {
    @Resource
    private ISaleAdService iSaleAdService;
    /**
     * 获取所有广告列表（下架的）
     */
    @GetMapping("/list")
    public ResponseResult<List<SaleAdDomain>> selectAll(){
        Wrapper wrapper= Wrappers.<SaleAdDomain>lambdaQuery().eq(SaleAdDomain::getIsEnabled,true);
        return ResponseResult.success(this.iSaleAdService.list(wrapper));
    }
}
